<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/element.css" />
		<link rel="stylesheet" type="text/css" href="css/reset.css" />
		<link rel="stylesheet" type="text/css" href="css/yp.css" />
		<link rel="stylesheet" type="text/css" href="css/common.css" />
		<script src="js/jquery-3.5.1.js"></script>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/element.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			[v-cloak] {
				display: none;
			}
		</style>
	</head>
	<body>
		<div id="app" v-cloak>
			<div class="page_root yp_page">
				<el-card class="box-card" shadow="never">
					<div class="yp_top">
						<span>CSTC/NQ-01</span>
						<span>广州市农作物种子质量检验中心</span>
					</div>
					<div class="title title1">种 子 检 验 扦 样 单</div>
					<div class="yp_form">
						<el-form :model="form" label-width="140px">
							<el-row>
								<el-col :span="8">
									<el-form-item label="样品编号:">
										<el-input v-model="form.sampleNo" :disabled="index!=0"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8" :offset="8">
									<el-form-item label="受检单位类型">
										<el-select v-model="form.companyType" placeholder="请选择" @change="companyTypeSelect" :disabled="index!=0">
											<el-option label="企业" value="企业"></el-option>
											<el-option label="门店" value="门店"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
							</el-row>
							<el-divider content-position="left">受检单位</el-divider>
							<el-row>
								<el-col :span="10">
									<el-form-item label="单位名称">
										<el-input v-model="form.companyName" :disabled="index!=0"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="10" :offset="4">
									<el-form-item label="法人代表">
										<el-input v-model="form.lealPerson" :disabled="index!=0"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="10">
									<el-form-item label="通讯地址">
										<el-input v-model="form.address" :disabled="index!=0"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="10" :offset="4">
									<el-form-item label="邮政编码">
										<el-input v-model="form.postcode" :disabled="index!=0"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="10">
									<el-form-item label="联系人">
										<el-input v-model="form.contacts" :disabled="index!=0"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="10" :offset="4">
									<el-form-item label="电话/传真">
										<el-input v-model="form.tel" :disabled="index!=0"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-divider content-position="left">生产商</el-divider>
							<el-row>
								<el-col :span="10">
									<el-form-item label="生产商">
										<el-input v-model="form.producer"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="10" :offset="4">
									<el-form-item label="邮政编码">
										<el-input v-model="form.postcode2"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="10">
									<el-form-item label="通讯地址">
										<el-input v-model="form.address2"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="10" :offset="4">
									<el-form-item label="电话/传真">
										<el-input v-model="form.tel2"></el-input>
									</el-form-item>
								</el-col>
							</el-row>

							<el-divider content-position="left">扦样信息</el-divider>
							<el-row>
								<el-col :span="10">
									<el-form-item label="作物种类">
										<el-select v-model="form.cropType" placeholder="请选择" @change="cropSelect">
											<el-option v-for="item in cropSpecies" :key="item.value" :label="item.label" :value="item.value">
											</el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="10" :offset="4">
									<el-form-item label="种子类别">
										<el-select v-model="form.seedType" placeholder="请选择">
											<el-option v-for="item in seedSpecies" :key="item.value" :label="item.label" :value="item.value">
											</el-option>
										</el-select>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="10">
									<el-form-item label="品种名称">
										<el-input v-model="form.cropName"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="10" :offset="4">
									<el-form-item label="批号">
										<el-input v-model="form.lotNum"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>

								<el-col :span="14">
									<el-row :gutter="20">
										<el-col :span="16">
											<el-form-item :label="form.bzLabel">
												<el-input v-model="form.bzDate"></el-input>
												<!--<el-date-picker type="month" placeholder="选择日期" v-model="form.bzDate" style="width: 100%;"-->
												 <!--value-format='yyyy年MM月' format='yyyy年MM月'></el-date-picker>-->
											</el-form-item>
										</el-col>
										<el-col :span="8">
											<el-form-item label-width='0'>
												<el-switch v-model="form.bzActive" active-text="包装" inactive-text="标签" @change="bzSwitch"></el-switch>
											</el-form-item>
										</el-col>
									</el-row>
								</el-col>
								<el-col :span="10" :offset="0">
									<el-form-item label="质量保证期">
										<el-input v-model="form.expiration"></el-input>
									</el-form-item>
								</el-col>
							</el-row>

							<el-row>
								<el-col :span="10">
									<el-form-item label="包装规格">
										<el-input v-model="form.packingSize"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="10" :offset="4">
									<el-form-item label="是否密封包装">
										<el-switch v-model="form.sealed"></el-switch>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="8">
									<el-form-item label="代表数量(kg)">
										<el-input v-model="form.count"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="样品重量(g)">
										<el-input v-model="form.weight"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="是否标注转基因">
										<el-switch v-model="form.gmo"></el-switch>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="12">
									<el-form-item label="扦样地点">
										<el-input v-model="form.sampleSite" :disabled="index!=0"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="扦样方式">
										<el-select v-model="form.sampleType" placeholder="请选择">
											<el-option label="小包装随机扦取" value="小包装随机扦取"></el-option>
											<el-option label="扦样器随机扦取" value="扦样器随机扦取"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="12">
									<el-form-item label="注册商标或标识">
										<el-input v-model="form.registeredMark"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="化学处理">
										<el-col :span="4">
											<el-switch v-model="form.chemical" active-value="有：" inactive-value="无"></el-switch>
										</el-col>
										<el-col :span="16">
											<el-input v-if='form.chemical=="有："' v-model="form.chemicalMsg" placeholder='化学处理内内容'></el-input>
										</el-col>
									</el-form-item>
								</el-col>
							</el-row>

							<el-row>
								<el-col :span="6">
									<el-form-item label="净度(%)" label-width="80px">
										<el-input v-model="form.si">
											<template slot="prepend">≥</template>
										</el-input>
									</el-form-item>
								</el-col>
								<el-col :span="6">
									<el-form-item label="发芽率(%)" label-width="80px">
										<el-input v-model="form.gr">
											<template slot="prepend">≥</template>
										</el-input>
									</el-form-item>
								</el-col>
								<el-col :span="6">
									<el-form-item label="纯度(%)" label-width="80px">
										<el-input v-model="form.purity">
											<template slot="prepend">≥</template>
										</el-input>
									</el-form-item>
								</el-col>
								<el-col :span="6">
									<el-form-item label="水分(%)" label-width="80px">
										<el-input v-model="form.water">
											<template slot="prepend">≤</template>
										</el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-form-item label="检验项目">
								<el-select style="width:300px" v-model="form.testItem" multiple placeholder="请选择">
									<el-option v-for="item in testTypes" :key="item.value"
									  :label="item.label" :value="item.value">
									</el-option>
								  </el-select>
							</el-form-item>

							<el-row>
								<el-col :span="12">
									<el-form-item label="检验方法">
										<el-input type="textarea" :rows="4" resize='none' v-model="form.testMethod"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="判定依据">
										<el-input type="textarea" :rows="4" resize='none' v-model="form.criterion"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-divider content-position="left">扦样单位</el-divider>

							<el-form-item label="检测单位">
								<el-input v-model="form.companyName2" :disabled="index!=0"></el-input>
							</el-form-item>
							<el-row>
								<el-col :span="12">
									<el-form-item label="通讯地址">
										<el-input v-model="form.address3" :disabled="index!=0"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="联系电话">
										<el-input v-model="form.tel3" :disabled="index!=0"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-form-item label="日期">
								<el-date-picker type="date" placeholder="选择日期" v-model="form.date" value-format='yyyy年MM月dd日' format='yyyy年MM月dd日'  :disabled="index!=0"></el-date-picker>
							</el-form-item>
							<el-form-item label="备注">
								<el-select v-model="form.remark" placeholder="请选择">
									<el-option label="广东省监督检验" value="广东省监督检验"></el-option>
									<el-option label="广州市监督检验" value="广州市监督检验"></el-option>
									<el-option label="储备种子质量检验" value="储备种子质量检验"></el-option>
								</el-select>
							</el-form-item>
						</el-form>
					</div>
				</el-card>
			</div>


		</div>

		<script>
			new Vue({
				el: '#app',
				data: {
					/** 基础参数 ***/
					cropSpecies: [],
					seedSpecies: [{
							value: '常规种',
							label: '常规种'
						},
						{
							value: '杂交种',
							label: '杂交种'
						},
						{
							value: '大田用种',
							label: '大田用种'
						},
					],
					testTypes:[
						{label:'净度',value:'净度'},
						{label:'纯度',value:'纯度'},
						{label:'水分',value:'水分'},
						{label:'发芽率',value:'发芽率'},
						{label:'转基因',value:'转基因'},
						{label:'真实性',value:'真实性'},
					],
					/*****/
					index:'0', // 当前页面数据在对应集合中下标
					ypItemActive: '1',
					ypList: [{
						title: '样品1',
						name: '1'
					}],

					form: {
						sampleNo: 'GZJ2105001',
						companyType: '1',
						companyName: '阿达',
						lealPerson: 'asda',
						address: 'asda',
						postcode: 'asdasdss',
						contacts: 'dwd',
						tel: '1234',
						producer: 'asd',
						postcode2: '34344',
						address2: 'ghgh',
						tel2: '576',
						cropType: '水稻',
						seedType: '常规种',
						bzActive: true,
						bzLabel: '包装标注检测日期',
						bzDate: '2021-09-10',
						expiration: '180天',
						lotNum: '120589623as',
						packingSize: 'sdasd',
						sealed: true,
						count: '12',
						weight: '3',
						gmo: true,
						sampleSite:'adw',
						sampleType:'1',
						registeredMark:'asdasda',
						chemical:true,
						testItem:[],
						testMethod:'dsds',
						criterion:'dsd',
						companyName2:'广州市农作物种子质量检验中心',
						address3:'广州市南沙区东涌镇市南路663号',
						tel3:'020-39004105',
						date:'2021-09-09',
						si:'≥98',
						gr:'≥98',
						purity:'≥98',
						water:'≥98',
                        remark:''
					}
				},
				watch: {
					// form监听
				    form: {
				         handler: function(val) {
							console.log(val)

							if(val.companyType == '企业'){
							    val.producer = val.companyName
							    val.postcode2 = val.postcode
							    val.address2 = val.address
							    val.tel2 = val.tel
							}

							var fy = window.cache.getItemData(this.index,'fy')
							fy.cropType = val.cropType
							fy.cropName = val.cropName
							fy.companyName = val.companyName
							window.cache.setItemData(fy,this.index,'fy')

							var letter = window.cache.getItemData(this.index,'letter')
							letter.companyName = val.companyName
							letter.sampleNo = val.sampleNo
							letter.no = val.sampleNo.substring(3)
							letter.cropType = val.cropType
							letter.cropName = val.cropName
							letter.producer = val.producer
							letter.bzDate = val.bzDate
							letter.qualityIndex = '净度≥' + val.si + ', 发芽率≥' + val.gr + ', 纯度≥' + val.purity + ', 水分≤' + val.water
							letter.seedType = val.seedType
							letter.packingSize = val.packingSize
							letter.address2 = val.address2
							letter.tel2 = val.tel2
							letter.lotNum = val.lotNum

							var bg1 = window.cache.getItemData(this.index,'bg1')
							bg1.sampleNo = val.sampleNo
							bg1.companyName = val.companyName
							bg1.producer = val.producer
							bg1.cropType = val.cropType
							bg1.cropName = val.cropName
							bg1.bzLabel = val.bzLabel
							bg1.bzDate = val.bzDate
							bg1.date = val.date
							bg1.expiration = val.expiration
							bg1.lotNum = val.lotNum
							bg1.count = val.count
							bg1.weight = val.weight
							bg1.sampleSite = val.sampleSite
							bg1.registeredMark = val.registeredMark
							bg1.qualityIndex = '净度≥' + val.si + ', 发芽率≥' + val.gr + ', 纯度≥' + val.purity + ', 水分≤' + val.water
							bg1.year = val.date.substring(0,4)

							var bg2 = window.cache.getItemData(this.index,'bg2')
							bg2.si = '≥' + val.si
							bg2.gr = '≥' + val.gr
							bg2.water = '≤' + val.water
							bg2.cropType = val.cropType
						},
				        deep: true
				    },
				},
				
				created() {
					window.cache = window.parent.cache;
					this.initParam()
					this.index = location.href.substring(location.href.lastIndexOf("=")+1) - 1
					this.getData(this.index)
				},
				 
				methods: {

					bzSwitch(val) {
						if (val) {
							this.form.bzLabel = '包装标注检测日期'
						} else {
							this.form.bzLabel = '标签标注检测日期'
						}
						window.cache.xcjl.descList[13][0] = this.form.bzLabel
						console.log(this.form)
					},

					// 农作物select监听
					cropSelect(val){
						var arr = window.cache.testParam
						var bg1 = window.cache.getItemData(this.index,'bg1')
						for (var i = 0; i < arr.length; i++) {
							if(arr[i].c0 == val){
								this.form.testMethod=arr[i].c1
								this.form.criterion=arr[i].c2
								bg1.testMethod = arr[i].c3
								bg1.criterion = arr[i].c4
                                bg1.testItem = arr[i].c5
                                bg1.instrument = arr[i].c6
                                var conclusion = '依据《农作物种子检验规程》（GB/T 3543.1~7-1995），对样品的&1&进行检验；根据&2&，判定该批种子所检项目的检测指标均符合要求。';
								bg1.conclusion = conclusion.replace('&1&',arr[i].c5)
																.replace('&2&',arr[i].c7)
								break
							}
						}
					},
					// 公司类型选择器
					companyTypeSelect(val){
						var xcjl = window.cache.xcjl
						xcjl.descList[3][0] = val == '企业' ? '繁种总量(kg)' : '';
						xcjl.descList[4][0] = val == '企业' ? '繁种时间' : '进货时间';
						xcjl.descList[5][0] = val == '企业' ? '繁种地点' : '进货地点';
						xcjl.descList[6][0] = val == '企业' ? '繁种价' : '进货价';
						xcjl.descList[7][0] = val == '企业' ? '繁种联系人' : '进货联系人';
						xcjl.descList[10][0] = val == '企业' ? '已加工包装(kg)' : '进货总量(kg)';
						xcjl.descList[11][0] = val == '企业' ? '入库时间' : '';

						if(val != '企业'){
						    this.form.producer = ''
                            this.form.postcode2 = ''
                            this.form.address2 = ''
                            this.form.tel2 = ''
                        }else{
                            this.form.producer = this.form.companyName
                            this.form.postcode2 = this.form.postcode
                            this.form.address2 = this.form.address
                            this.form.tel2 = this.form.tel
                        }
					},
                    companyNameInput(val){
					    if(this.form.companyType == '企业'){
					        this.form.producer = val
                        }
                    },
					
					/**************************/
					getData(){
						var obj = window.cache.getItemData(this.index,'sample')
						// 其他页面部分数据公用第一个
						if(this.index != 0){
						    debugger
                            var first = window.cache.getItemData(0,'sample')
							obj.date = first.date
							obj.companyType = first.companyType
							obj.lealPerson = first.lealPerson
							obj.companyName = first.companyName
							obj.address = first.address
							obj.postcode = first.postcode
							obj.contacts = first.contacts
							obj.tel = first.tel
							// obj.postcode2 = first.postcode2
							obj.sampleSite = first.sampleSite
							obj.date = first.date
							obj.companyName2 = first.companyName2
							obj.tel3 = first.tel3
							obj.address3 = first.address3


							var no = first.sampleNo
                        	var v1 = no.substring(0,3);
                        	var v2 = no.substring(3);
                        	if(v2){
                        	    v2 = parseInt(v2) + parseInt(this.index)
							}
							obj.sampleNo = v1 + v2

						}

						this.form = obj
					},
					
					initParam(){
						var arr = window.cache.testParam
						var cropSpecies = []
						for (var i = 0; i < arr.length; i++) {
							cropSpecies.push({label:arr[i].c0, value:arr[i].c0})
						}
						this.cropSpecies = cropSpecies
					},

				}
			})
		</script>
	</body>
</html>
